<?php

namespace maotool\util;

use DateTime;

/**
 * 周
 */
class WeekUtil
{

    /**
     * 当前周 数字形式
     * @return false|string
     */
    public static function current()
    {
        return date("w");
    }

    /**
     * 当前周 数字形式
     * @return array
     */
    public static function currentDates()
    {
        $timestamp = time();
        $dayOfWeek = date('w', $timestamp);
        $monday = strtotime("-$dayOfWeek day", $timestamp);
        $weekDates = [];
        for ($i = 1; $i <= 7; $i++) {
            $weekDates[] = date('Y-m-d', strtotime("+$i day", $monday));
        }
        return $weekDates;
    }

    /**
     * 当前周 英文
     * @return string|null
     */
    public static function currentEn()
    {
        return WordsUtil::lowerFirst(date("l"));
    }

    /**
     * 当前周 中文形式
     * @return string
     */
    public static function currentCn()
    {
        $index = date('w');
        $map = ["日", "一", "二", "三", "四", "五", "六"];
        return $map[$index];
    }

    /**
     * 当前周 映射形式
     * @return string
     */
    public static function currentMap($map = [7, 1, 2, 3, 4, 5, 6])
    {
        $index = date('w');
        return $map[$index];
    }

}